import { createRouter, createWebHistory } from 'vue-router'
import LoginView from '../views/Login/LoginView.vue'
import RegisterView from '../views/Login/RegisterView.vue'
import HomeView from '../views/Home/HomeView.vue'
import LayoutView from '../components/LayoutView.vue'
import MedecineBuy from '@/views/MedecineManage/MedecineBuy.vue'
import MedecineCategory from '@/views/MedecineManage/MedecineCategory.vue'
import MedecineDetail from '@/views/MedecineManage/MedecineDetail.vue'
import MedecineSale from '@/views/MedecineManage/MedecineSale.vue'
import StaffManage from '@/views/StaffManage/StaffManage.vue'
import VIPManage from '@/views/VIPManage/VIPManage.vue'
import OrderCheck from '@/views/OrderCheck/OrderCheck.vue'
import TotalData from '@/views/TotalData/TotalData.vue'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/login',
      name: 'login',
      component: LoginView,
    },
    {
      path: '/register',
      name: 'register',
      component: RegisterView,
    },
    {
      path: '/',
      name: 'layout',
      component: LayoutView,
      redirect: '/login',
      children: [
        {
          path: '/home',
          name: 'home',
          component: HomeView,
          meta: {
            title: '首页',
          },
        },
        {
          path: '/medecine',
          name: 'medecine',
          meta: {
            title: '药品管理',
          },
          children: [
            {
              path: '/medecine/buy',
              name: 'medecine-buy',
              component: MedecineBuy,
              meta: {
                title: '药品采购',
              },
            },
            {
              path: '/medecine/category',
              name: 'medecine-category',
              component: MedecineCategory,
              meta: {
                title: '药品分类',
              },
            },
            {
              path: '/medecine/detail',
              name: 'medecine-detail',
              component: MedecineDetail,
              meta: {
                title: '药品详情',
              },
            },
            {
              path: '/medecine/sale',
              name: 'medecine-sale',
              component: MedecineSale,
              meta: {
                title: '药品销售',
              },
            },
          ],
        },
        {
          path: '/orderCheck',
          name: 'orderCheck',
          component: OrderCheck,
          meta: {
            title: '订单审核',
          },
        },
        {
          path: '/staffManage',
          name: 'staff',
          component: StaffManage,
          meta: {
            title: '员工管理',
          },
        },
        {
          path: '/vipManage',
          name: 'vip',
          component: VIPManage,
          meta: {
            title: '会员管理',
          },
        },
        {
          path: '/totalData',
          name: 'totalData',
          component: TotalData,
          meta: {
            title: '销售数据',
          },
        },
        {
          path: '/userCenter',
          name: 'userCenter',
          component: () => import('../views/UserCenter/UserCenter.vue'),
          meta: {
            title: '个人中心',
          },
        },
      ],
    },
  ],
})

export default router
